#pragma once

#include"Common.h"
#include"BuildTask.h"
#include"UnitControlerBaseClass.h"

class ProductionTask;
class BaseInfo;

class DroneControler : public UnitControlerBaseClass
{
public:
	enum State{IdleDrone , Mining , Gasing , PlaceBuilding};
	//--
	DroneControler(Unit* drone);
	virtual void OnFrame();
	virtual bool ShouldRemove();
	void Build(UnitType unitType , int baseIndex);
	void Build(ProductionTask& productionTask);
	void HarvestGas(Unit* geyser);
	State GetState() const
	{
		return _state;
	}
private:
	void IdleFunction();
	void MiningFunction();
	void GasingFunction();
	void PlaceBuildingFunction();
	void LeaveBase();
	bool IsMiningOrder(const Order& order);
	bool IsGasingOrder(const Order& order);
	bool ShouldStartBuild() const;
	void Draw();
	//--
	bool _IamDead;
	State _state;
	int _notMiningFrameCount;
	const int _notMiningFrameMax;
	BaseInfo* _inThisBase;

	BuildTask _buildTask;
	double _distanceToTarget;
	ProductionTask* _productionTask;
};